package com.candy.control;

import com.candy.bean.LoginInfo;
import com.candy.service.UserManager;
import com.candy.service.impl.UserManagerImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/getUserInfoAjaxServlet")
public class GetUserInfoAjaxServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserManager userManager = new UserManagerImpl();
        List<LoginInfo> lb=null;

        try {
            lb = userManager.getUserInfoes();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        // 使用out对象(PrintWriter)将响应内容，输出给ajax引擎对象
        PrintWriter printWriter = resp.getWriter();
        // 发送响应内容到浏览器的ajax引擎
        printWriter.println(lb);



    }
}

